//
//  InstamentScheduleCell.m
//  JinFuThree
//
//  Created by 毛韶谦 on 2018/9/11.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "InstamentScheduleCell.h"


@interface InstamentScheduleCell ()

@property (nonatomic, strong) UIImageView *leftCircleImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *infoLabel;
@property (nonatomic, strong) UILabel *timeLabel;

@end

@implementation InstamentScheduleCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self.leftCircleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(10, 10));
            make.left.mas_equalTo(self.contentView.mas_left).offset(20);
        }];
        [self.leftTopImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentView);
            make.width.mas_equalTo(0.5);
            make.bottom.mas_equalTo(self.leftCircleImageView.mas_centerY);
            make.centerX.mas_equalTo(self.leftCircleImageView.mas_centerX);
        }];
        [self.leftBottomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self.contentView);
            make.width.mas_equalTo(0.5);
            make.top.mas_equalTo(self.leftCircleImageView.mas_centerY);
            make.centerX.mas_equalTo(self.leftCircleImageView.mas_centerX);
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.leftCircleImageView.mas_right).offset(15);
            make.bottom.mas_equalTo(self.leftCircleImageView.mas_bottom);
        }];
        [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.leftCircleImageView.mas_right).offset(15);
            make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-5);
        }];
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView.mas_right).offset(-20);
            make.centerY.mas_equalTo(self.titleLabel);
        }];
        
        [self.contentView bringSubviewToFront:self.leftCircleImageView];
    }
    return self;
}

- (void)updateInfoCellWithModel:(NSIndexPath *)indexPath {
    
    self.titleLabel.text = @"信审驳回";
    self.timeLabel.text = @"04/08 09:25";
    self.infoLabel.text = @"手持身份证照片不清晰";
    
    if (indexPath.row == 3) {
        self.leftCircleImageView.image = [UIImage imageNamed:@"checked_jieDai"];
        self.titleLabel.textColor = ThemeMaoColor;
        self.infoLabel.textColor = ThemeMaoColor;
    }else {
        self.leftCircleImageView.image = [UIImage imageNamed:@"oval_jieDai"];
        self.titleLabel.textColor = HexColor(0x333333);
        self.infoLabel.textColor = HexColor(0x333333);
    }
}

- (UILabel *)titleLabel {
    
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = HexColor(0x333333);
        _titleLabel.font = [UIFont boldSystemFontOfSize:14];
        
        [self.contentView addSubview:_titleLabel];
    }
    return _titleLabel;
}
- (UILabel *)infoLabel {
    
    if (!_infoLabel) {
        _infoLabel = [[UILabel alloc] init];
        _infoLabel.textColor = HexColor(0x999999);
        _infoLabel.font = [UIFont systemFontOfSize:12];
        _infoLabel.numberOfLines = 0;
        
        [self.contentView addSubview:_infoLabel];
    }
    return _infoLabel;
}
- (UILabel *)timeLabel {
    
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.textColor = HexColor(0x999999);
        _timeLabel.font = [UIFont systemFontOfSize:12];
        
        [self.contentView addSubview:_timeLabel];
    }
    return _timeLabel;
}

- (UIImageView *)leftCircleImageView {
    
    if (!_leftCircleImageView) {
        _leftCircleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checked_jieDai"]];
        [_leftCircleImageView setContentMode:UIViewContentModeScaleAspectFit];
        _leftCircleImageView.layer.cornerRadius = 5;
        _leftCircleImageView.layer.masksToBounds = YES;
        
        [self.contentView addSubview:_leftCircleImageView];
    }
    return _leftCircleImageView;
}

- (UIImageView *)leftTopImageView {
    
    if (!_leftTopImageView) {
        _leftTopImageView = [[UIImageView alloc] init];
        _leftTopImageView.backgroundColor = HexColor(0xAAAAAA);
        
        [self.contentView addSubview:_leftTopImageView];
    }
    return _leftTopImageView;
}
- (UIImageView *)leftBottomImageView {
    
    if (!_leftBottomImageView) {
        _leftBottomImageView = [[UIImageView alloc] init];
        _leftBottomImageView.backgroundColor = HexColor(0xAAAAAA);
        
        [self.contentView addSubview:_leftBottomImageView];
    }
    return _leftBottomImageView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
